package com.shk.service.imp;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.shk.dao.CheckItemDao;
import com.shk.entity.PageResult;
import com.shk.entity.QueryPageBean;
import com.shk.entity.Result;
import com.shk.pojo.CheckItem;
import com.shk.service.CheckItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service(interfaceClass = CheckItemService.class)
@Transactional
public class CheckItemServiceImpl implements CheckItemService {
    @Autowired
    private CheckItemDao checkItemDao;
    @Override
    public void add(CheckItem checkItem) {
        checkItemDao.add(checkItem);
    }


    @Override
    public PageResult findPage(Integer currentPage,Integer pageSize,String queryString) {
        PageHelper.startPage(currentPage,pageSize);
        Page<CheckItem> page = checkItemDao.findPage(queryString);
        long total = page.getTotal();
        List<CheckItem> rows = page.getResult();
        return new PageResult(total,rows);
    }

    @Override
    public void deleteById(Integer id) {
        checkItemDao.deleteById(id);
    }

    @Override
    public CheckItem findById(Integer id) {
      return checkItemDao.findById(id);

    }

    @Override
    public void edit(CheckItem checkItem) {
         checkItemDao.edit(checkItem);
    }

    @Override
    public List<CheckItem> findAll() {
       return checkItemDao.findAll();
    }



}
